local longnu = fk.CreateSkill {
  name = "mini__longnu",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["mini__longnu"] = "龙怒",
  [":mini__longnu"] = "锁定技，出牌阶段开始时，你选择一项："..
  "1.失去1点体力并摸两张牌，本回合你的红色手牌均视为火【杀】且使用火【杀】无距离限制；"..
  "2.减1点体力上限，本回合你的黑色手牌均视为雷【杀】且使用雷【杀】无次数限制。",

  ["mini__longnu_hp"] = "失去1点体力并摸两张牌，本回合红色手牌视为火【杀】且无距离限制",
  ["mini__longnu_maxhp"] = "减1点体力上限，本回合黑色手牌视为雷【杀】且无次数限制",

  ["$mini__longnu1"] = "怒伤心肝也阻止不了这复仇之火！",
  ["$mini__longnu2"] = "灼艾分痛失，虽万劫亦杀之！",
}

longnu:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(longnu.name) and player.phase == Player.Play
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = room:askToChoice(player, {
      choices = { "mini__longnu_hp", "mini__longnu_maxhp" },
      skill_name = longnu.name,
    })
    if choice == "mini__longnu_hp" then
      room:loseHp(player, 1, longnu.name)
      if player.dead then return end
      player:drawCards(2, longnu.name)
      if player.dead then return end
      room:setPlayerMark(player, "mini__longnu-turn", "yang")
    else
      room:changeMaxHp(player, -1)
      if player.dead then return end
      room:setPlayerMark(player, "mini__longnu-turn", "yin")
    end
  end,
})

longnu:addEffect("filter", {
  anim_type = "offensive",
  card_filter = function(self, to_select, player)
    if player:hasSkill(longnu.name) and
    table.contains(player:getCardIds("h"), to_select.id) then
      if player:getMark("mini__longnu-turn") == "yang" then
        return to_select.color == Card.Red
      elseif player:getMark("mini__longnu-turn") == "yin" then
        return to_select.color == Card.Black
      end
    end
  end,
  view_as = function(self, player, to_select)
    local card
    if player:getMark("mini__longnu-turn") == "yang" then
      card = Fk:cloneCard("fire__slash", to_select.suit, to_select.number)
    elseif player:getMark("mini__longnu-turn") == "yin" then
      card = Fk:cloneCard("thunder__slash", to_select.suit, to_select.number)
    end
    card.skillName = longnu.name
    return card
  end,
})

longnu:addEffect("targetmod", {
  bypass_distances =  function(self, player, skill, card, to)
    return player:getMark("mini__longnu-turn") == "yang" and card and card.name == "fire__slash"
  end,
  bypass_times = function(self, player, skill, scope, card, to)
    return player:getMark("mini__longnu-turn") == "yin" and card and card.name == "thunder__slash"
  end,
})

return longnu
